#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_ttf.h>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

#include "application.h"
#include "constants.h"
#include "events.h"
#include "functions.h"
#include "Arena.h"
#include "Bdesyn.h"
//#include "grids.h"
#include "fonts.h"

int main( int argc, char* args[] )
{
	string title="Disc Warriors";
	Application DiscWarriors(argc,args);
	SDL_Surface* screen=DiscWarriors.gameInit(306,200,32,title,30);
	
	SDL_Color black={0,0,0};
	SDL_Surface* back;
	SDL_Surface* temp;
	
	cout<<"before load"<<endl;
	Font arial("arial.ttf",12,black);
	cout<<"after load"<<endl;
	
	SDL_Event ev;
	
	Handler events;
	
	back=loadImage("back.png");
	temp=loadImage("krake_D.png");
	
	//Arena()
	
	//Bdesyn krake("krake",0,24);
    	Bdesyn krake(temp,0,24);
    	
    	string bC;
    	int _x;
    	int _y;
	
	while(!DiscWarriors.stopped())
	{
		_x=krake.getCord(0);
		_y=krake.getCord(1);
		bC=to_string(_x)+", "+to_string(_y);
		//cout<<"Game loop entered"<<endl;
		blit(0,0,back,screen);
		krake.drawSprite(screen);
		cout<<"Krake blit"<<endl;
		arial.write(bC,0,0);
		cout<<"text blit"<<endl;
		SDL_Flip(screen);

		cout<<"Screen flipped"<<endl;
                
          krake.move(events);
		
		while(SDL_PollEvent(&ev))
		{
			if(ev.type==SDL_QUIT)
			{
				DiscWarriors.gameEnd();
			}
		}
		DiscWarriors.regulateFPS();
	}
	SDL_FreeSurface(screen);
	SDL_FreeSurface(back);
	SDL_Quit(); 
	return 0; 
}
